package com.course.coursedesign2022.service;

import com.course.coursedesign2022.mapper.UserMapper;
import com.course.coursedesign2022.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FollowUp {

    @Autowired
    private UserMapper userMapper;


    public UserInfo followUp(Integer id){
        //读取数据
        UserInfo userInfoById = userMapper.getUserInfoById(id);
        Integer exchangescore = userInfoById.getExchangescore();
        Integer scoreTotal = userInfoById.getScoretotal();
        //完成门诊随访，增加3可兑换积分
        exchangescore += 3;
        scoreTotal += 3;
        System.out.println("完成门诊随访，增加3可兑换积分");
        System.out.println("成长积分为："+ userInfoById.getGrowscore());
        System.out.println("可交换积分为："+ userInfoById.getExchangescore());
        System.out.println("总积分为："+ userInfoById.getScoretotal());

        //写回数据库
        userInfoById.setExchangescore(exchangescore);
        userInfoById.setScoretotal(scoreTotal);
        userMapper.updateUserInfo(userInfoById);
        return userInfoById;
    }
}
